<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{
    /**
     * 后台登录
     */
    public function login()
    {
        if(IS_POST){
            $aModel = D('Admin');
            //接收并验证表单
            if($aModel->validate($aModel->_login_validate)->create()){
//                dump($aModel);exit();
                if($aModel->login()){
                    $this->success('登录成功',U('Index/index'));
                    exit();
                }
            }
            $this->error($aModel->getError());
        }
        //
//        $model = D('Admin');
//        $ret= $model ->chkCode();
//        dump($ret);exit();
        $this->display();
    }

    /**
     * 退出登录
     */
    public function logout()
    {
        $model = D('Admin');
        $model->logout();
        redirect('login');
    }
    /**
     * 制作验证码
     */
    public function chkcode(){
        $Verify = new \Think\Verify(array(
            'fontSize'  =>20,
            'length'  =>'4',
            'useNoise' =>'TRUE',
        ));
        $Verify->entry();
    }
}